<?php

require_once 'Basic.php';

class FormFieldCategoryCNH extends FormFieldType {

  private static $possibleValues = array (
  	"a", "b", "c", "d", "e", "ab", "ac", "ad", "ae"
  );
	
  public function __construct($nonempty = false) {
    $this->htmlId = null;
    $this->inputSize = 30;
    $this->htmlClass = "catCNHField";
  }
  
  public function getHtml($name, $value = null) {
    return $this->commonHtml($name,$value);
  }
  
  public function validate($input) {
  	$input = strtolower($input);
    if(array_search($input, FormFieldCategoryCNH::$possibleValues) !== false) {
    	return true;
    }
    else {
    	return htmlentities("Sua CNH pode ser do tipo A,B,C,D,E ou uma combinação do A com B,C,D,E");
    }
  }
  
  public function clearHtmlClass() {
    $this->htmlClass = "catCNHField";
  }
  
}
